package com.jalarbee.liquid.services.dao.impl;

import com.jalarbee.core.generic.dao.DataAcessException;
import com.jalarbee.core.generic.dao.impl.GenericDaoJpa;
import com.jalarbee.liquid.services.business.Service;
import com.jalarbee.liquid.services.dao.ServiceDao;
import com.jalarbee.stock.category.business.Category;
import java.util.List;
import javax.inject.Named;
import javax.persistence.Query;

/**
 *
 * @author Abdoul
 */

@Named(value="serviceDao")
public class ServiceDaoJpa extends GenericDaoJpa<Service, Integer> implements ServiceDao {

    public List<Service> getServices() throws DataAcessException {
        return getEntityManager().createQuery("from Service"). getResultList();
    }

    public List<Service> getServicesByCategory(Category category) throws DataAcessException {
        Query q = getEntityManager().createQuery("from Service s where s.type=:category");
        q.setParameter("category", category);
        return q.getResultList();
    }

}
